package test1;
import java.util.Random;

public class Main {
    public static void main(String[] args) {
        int classNum = 3;//班级个数

        //定义3个班级
        Holeclass class1 = new Holeclass("1班");
        Holeclass class2 = new Holeclass("2班");
        Holeclass class3 = new Holeclass("3班");

        //定义班级小组
        Holeclass [] classes = new Holeclass[10];
        classes[0] = class1;
        classes[1] = class2;
        classes[2] = class3;

        //定义18名学生
        Student student1 = new Student("周清");
        Student student2 = new Student("李明");
        Student student3 = new Student("王五");
        Student student4 = new Student("李四");
        Student student5 = new Student("孟一");
        Student student6 = new Student("周周");
        Student student7 = new Student("孟非");
        Student student8 = new Student("李三");
        Student student9 = new Student("孟听");
        Student student10 = new Student("张新");
        Student student11 = new Student("琳琳");
        Student student12 = new Student("王七");
        Student student13 = new Student("飞飞");
        Student student14 = new Student("马三");
        Student student15 = new Student("莹莹");
        Student student16 = new Student("果果");
        Student student17 = new Student("李学");
        Student student18 = new Student("张张");


        //初始化班级学生人数，并将学生存入班级数组
        classes[0].students[0] = student1;
        classes[0].students[1] = student2;
        classes[0].students[2] = student3;
        classes[0].students[3] = student4;
        classes[0].students[4] = student5;
        classes[0].students[5] = student6;

        classes[1].students[0] = student7;
        classes[1].students[1] = student8;
        classes[1].students[2] = student9;
        classes[1].students[3] = student10;
        classes[1].students[4] = student11;
        classes[1].students[5] = student12;

        classes[2].students[0] = student13;
        classes[2].students[1] = student14;
        classes[2].students[2] = student15;
        classes[2].students[3] = student16;
        classes[2].students[4] = student17;
        classes[2].students[5] = student18;

        //将所有的学生存入一个数组中
        Student [] allStudents = new Student[100];
        allStudents[0] = student1;
        allStudents[1] = student2;
        allStudents[2] = student3;
        allStudents[3] = student4;
        allStudents[4] = student5;
        allStudents[5] = student6;
        allStudents[6] = student7;
        allStudents[7] = student8;
        allStudents[8] = student9;
        allStudents[9] = student10;
        allStudents[10] = student11;
        allStudents[11] = student12;
        allStudents[12] = student13;
        allStudents[13] = student14;
        allStudents[14] = student15;
        allStudents[15] = student16;
        allStudents[16] = student17;
        allStudents[17] = student18;



        //初始化每班的小组数组
        for(int i=0;i<classNum;i++){
            for(int j=0;j<classes[i].groupNum;j++){
                classes[i].groups[j] = new Group((j+1)+"组");
            }
        }
        int cnt = 0;
        for(int i=0;i<classNum;i++){
            for(int j=0;j<classes[i].groupNum;j++){
                classes[i].groups[j].students1[0] = allStudents[cnt];
                cnt++;
                classes[i].groups[j].students1[1] = allStudents[cnt];
                cnt++;
            }
        }

        //随机抽取班级
        Random random1 = new Random();
        int n1 = random1.nextInt(classNum);
        System.out.println("随机抽取到的班级为：" + classes[n1].className);

        //随机抽取小组
        Random random2 = new Random();
        int n2 = random2.nextInt(classes[n1].groupNum);
        System.out.println("随机抽取到的小组是：" + classes[n1].className + classes[n1].groups[n2].groupName);

        //随机抽取该小组的学生
        Random random3 = new Random();
        int n3 = random3.nextInt(2);
        System.out.println("随机抽取到该小组的学生为：" + classes[n1].className + classes[n1].groups[n2].groupName + classes[n1].groups[n2].students1[n3].studentName);

        //随机抽取该班的学生
        Random random4 = new Random();
        int n4 = random4.nextInt(classes[n1].studentNum);
        System.out.println("随机抽取到该班的学生为：" + classes[n1].students[n4].studentName);



    }
}
